################################################################################
## Group Identities and Parliamentary Debates: Replication package
## Fiva, Nedregård and Øien (2024)

# Description:

## Code to make Table A8: "Most divergent words across age groups"

################################################################################

library(xtable)
library(data.table)

# Directories (wd is set by master.R)
data.dir <-  "../data/3_model_output"
tab.dir  <- "../results/tables"

# Reading top50 divergent words

t <- fread(paste(data.dir, "di_trans_words_top50_age.csv", sep = "/"))

t <- t[, .(rank, 
           words_old, words_old_translated, n_words_old_by_old, 
           n_words_old_by_0, words_0, words_0_translated, n_words_0_by_old, 
           n_words_0_by_0)]


# saving to latex table

t <- xtable(t, method = c("compact"), booktabs = T)



print.xtable(t, only.contents = T, comment = F, hline.after = NULL, 
             include.colnames = F, include.rownames = F, 
             file = paste(tab.dir, "tabA8.tex", sep = "/"))









